#include "CocosPCH.h"
#include "Particle3DViewer.h"

#include "Particle3D/CCParticle3DEmitter.h"
#include "Particle3D/CCParticle3DAffector.h"
#include "Particle3D/CCParticle3DRender.h"
#include "Particle3D/PU/CCPUMaterialManager.h"

Particle3DViewer2::Particle3DViewer2()
{
    m_bHasExportOne = false;
    m_bHasExportAll = false;
}

ui::Widget* Particle3DViewer2::createItem(int nIndex, std::string strName)
{
    auto button = ui::Button::create("Button_Normal.png");
    button->setContentSize(Size(104, 40));
    button->setScale9Enabled(true);
    button->setTitleText(strName);
    button->setTitleFontSize(15);
    button->setTitleColor(Color3B(0, 0, 0));

    return button;
}

void Particle3DViewer2::initSearchPath()
{
    vector<std::string> vecSearPath = FileUtils::getInstance()->getSearchPaths();
    vecSearPath.push_back("Particle3D");
    vecSearPath.push_back("Particle3D/materials");
    vecSearPath.push_back("Particle3D/scripts");
    vecSearPath.push_back("Particle3D/textures");
    FileUtils::getInstance()->setSearchPaths(vecSearPath);
}

bool Particle3DViewer2::LoadFile(std::string strPath)
{;

    auto rootps = PUParticleSystem3D::create(strPath);
    if (!rootps)
        return false;

    BaseViewer::LoadFile(strPath);

    rootps->setCameraMask((unsigned short)CameraFlag::USER1);
    rootps->startParticleSystem();
    _orginCenter = Vec3(0.0f, 0.0f, 0.0f);
    _orginDistance = 50.0f;
    m_pViewNode->addChild(rootps);

    setCamera();
    resetCamera();

    return true;
}


void Particle3DViewer2::ClearCache()
{
}